package viterbi;


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

import common.ViterbiTaggerNew;

public class ViterbiTestSet {
	public static void main(String[] args) {
		// Read the words from the test set
		ArrayList<String> nbrs = new ArrayList<String>();
		ArrayList<String> words1 = new ArrayList<String>();
		ArrayList<String> words2 = new ArrayList<String>();
		ArrayList<String> words3 = new ArrayList<String>();

		try {
			File file = new File("CoNLL2009-ST-test-words.txt");
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line = null;
			while ((line = br.readLine()) != null) {
				if(line.isEmpty() || line.substring(0, 1).equals("\t")) continue;
				String[] cols = line.split("\t");
				nbrs.add(cols[0]);
				words1.add(cols[1]);
				words2.add(cols[2]);
				words3.add(cols[3]);
			}
		} catch (IOException x) {
			System.err.format("IOException: %s%n", x);
		}
		
		// Apply the Viterbi tagger on the test set
		ArrayList<String> pposViterbi = ViterbiTaggerNew.tag("CoNLL2009-ST-test-words.txt");
		
		for (int i=0; i<words1.size(); i++){
			if (i!=0 && words1.get(i).equals("1")){
				System.out.println();
			}
			System.out.println(nbrs.get(i) + "\t" + words1.get(i) + "\t" + words2.get(i) + "\t" + words3.get(i) + "\t" + pposViterbi.get(i));
		}
	}
}
